<%@ page contentType="text/html;charset=UTF-8" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <!--[if lt IE 9]>
    <script type="text/javascript" src="lib/html5shiv.js"></script>
    <script type="text/javascript" src="lib/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css"/>
    <link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin"/>
    <link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css"/>
    <!-- 引入样式 -->
    <link rel="stylesheet" href="static/element/index.css">
    <!--[if IE 6]>
    <script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js"></script>
    <script>DD_belatedPNG.fix('*');</script>
    <![endif]-->
    <title></title>
    <style>
        .fail .layui-layer-content {
            background-color: brown;
            color: #eee;
            width: 400px;
            height: 30px;
            text-align: center;
        }

        .succeed .layui-layer-content {
            background-color: #0061A8;
            color: #eee;
            width: 400px;
            height: 30px;
            text-align: center;
        }

        * {
            padding: 0;
            margin: 0;
        }

        html {
            overflow-y: hidden;
        }

        body, html {
            width: 100%;
            height: 100%;
        }

        body {
            display: flex;
            flex-flow: column;
        }

        .fheader {
            height: 1%;
            min-height: 95px;
        }

        .fsection {
            /*flex-grow: 1;*/
            display: flex;
            flex-flow: row;
            margin-top: 10px;
            /*height: 99%;*/
            min-height: 0;
        }

        .farticle {
            flex: 1;
            padding: 1px;
        }

        .el-table__body tr:hover > td {
            background-color: #DFDFDF !important;
            cursor: default
        }

    </style>
</head>
<body>
<div id="app">
    <div class="fheader" style="padding: 0;margin: 0 ">
        <nav class="breadcrumb" style="height: 100%; padding: 0;margin-top: 8px ">
            <el-row>
                <div class="l" style="margin-left: 20px; padding-top: 5px">
                    <span style="font-size: 20px; margin: 8px;">历史数据查询</span>

                    <el-date-picker
                            v-model="value2"
                            type="datetimerange"
                            range-separator="至"
                            start-placeholder="开始日期"
                            end-placeholder="结束日期"
                            format="yyyy-MM-dd"
                            value-format="yyyy-MM-dd"
                            align="right"
                            @change="fGet">
                    </el-date-picker>
                </div>
            </el-row>

            <el-row>
                <div class="l" style="margin-top: 5px; margin-left: 20px; ">
                    <el-select v-model="bmmc" placeholder="请选择部门" style="width: 280px">
                        <el-option
                                v-for="item in tableTree"
                                :key="item.VALUE01"
                                :label="item.VALUE01"
                                :value="item.VALUE01">
                        </el-option>
                    </el-select>
                </div>

                <div class="l">
                    <el-input type="text" class="input-text" style="border:0; margin-top: 1px;" v-model="ryxm" autocomplete="off" placeholder="人员姓名"></el-input>
                </div>
                <a class="btn btn-success radius l" style="line-height:1.6em;margin-top:10px; margin-left: 10px" @click="fBegin()" title="查询" v-loading.fullscreen.lock="fullscreenLoading">查询</a>
                <a class="btn btn-warning radius l" style="line-height:1.6em;margin-top:10px; margin-left: 10px" @click="fReset()" title="重置">重置</a>

                <span class="r">
                    <a style="margin-top: 10px" @click="fDown()" class="btn .btn-secondary radius">下一页</a>
                </span>
                <span class="r">
                    <a style="margin-top: 10px" @click="fUp()" class="btn .btn-secondary radius">上一页</a>
                </span>
                <span class="r" style="padding-top: 6px;">共有数据：[<strong>{{iiCount}}</strong> 条]</span>
            </el-row>
        </nav>
    </div>

    <div class="fsection">
        <div class="farticle">
            <div style="height: 100%; width: 100%; overflow: scroll; float: left; overflow-x: hidden;">
                <el-table v-if="nf==='2021'" :data="tableData" stripe border style="width: 100%" :height="tableHeightL" empty-text="没有数据" :header-cell-style="tableHeaderCellStyleL" :cell-style="tableCellStyleL">
                    <el-table-column prop="VALUE01" label="序号" width="80"></el-table-column>
                    <el-table-column prop="VALUE02" label="工号" width="100"></el-table-column>
                    <el-table-column prop="VALUE03" label="姓名" width="100"></el-table-column>
                    <el-table-column prop="VALUE04" label="部门"></el-table-column>
                    <el-table-column prop="VALUE05" label="补贴形式" width="90"></el-table-column>
                    <el-table-column prop="VALUE06" label="期初金额" width="90"></el-table-column>
                    <el-table-column prop="VALUE07" label="交易金额" width="90"></el-table-column>
                    <el-table-column prop="VALUE08" label="账户结余" width="90"></el-table-column>
                    <el-table-column prop="VALUE09" label="交易时间" width="150"></el-table-column>
                    <el-table-column prop="VALUE10" label="类型" width="130"></el-table-column>
                    <el-table-column prop="VALUE11" label="终端" width="160"></el-table-column>
                </el-table>
                <el-table v-else :data="tableData" stripe border style="width: 100%" :height="tableHeightL" empty-text="没有数据" :header-cell-style="tableHeaderCellStyleL" :cell-style="tableCellStyleL">
                    <el-table-column prop="VALUE01" label="序号" width="90"></el-table-column>
                    <el-table-column prop="VALUE02" label="工号" width="100"></el-table-column>
                    <el-table-column prop="VALUE03" label="姓名" width="100"></el-table-column>
                    <el-table-column prop="VALUE04" label="部门"></el-table-column>
                    <el-table-column prop="VALUE05" label="交易时间" width="160"></el-table-column>
                    <el-table-column prop="VALUE06" label="期初金额" width="90"></el-table-column>
                    <el-table-column prop="VALUE07" label="存钱金额" width="90">
                        <template slot-scope="scope">
                            <span v-if="scope.row.VALUE07 === '0.00'"></span>
                            <span v-else>{{scope.row.VALUE07}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="VALUE08" label="实际入账" width="90">
                        <template slot-scope="scope">
                            <span v-if="scope.row.VALUE08 === '0.00'"></span>
                            <span v-else>{{scope.row.VALUE08}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="VALUE09" label="管理费" width="90">
                        <template slot-scope="scope">
                            <span v-if="scope.row.VALUE09 === '0.00'"></span>
                            <span v-else>{{scope.row.VALUE09}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="VALUE10" label="消费金额" width="90">
                        <template slot-scope="scope">
                            <span v-if="scope.row.VALUE10 === '0.00'"></span>
                            <span v-else>{{scope.row.VALUE10}}</span>
                        </template>
                    </el-table-column>
                    <el-table-column prop="VALUE11" label="账户结余" width="90"></el-table-column>
                    <el-table-column prop="VALUE12" label="当前比率" width="70"></el-table-column>
                    <el-table-column prop="VALUE17" label="刷卡形式" width="70"></el-table-column>
                    <el-table-column prop="VALUE13" label="类型" width="110"></el-table-column>
                    <el-table-column prop="VALUE14" label="终端" width="140"></el-table-column>
                    <el-table-column prop="VALUE15" label="商户" width="80"></el-table-column>
                </el-table>
            </div>
        </div>
    </div>
</div>

<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="lib/Layui_30023/layui.all.js"></script>
<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="lib/layui_exts/excel.js"></script>
<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
<script type="text/javascript" src="static/axios.min.js"></script>
<script type="text/javascript" src="./static/vue"></script>
<script src="static/element/index.js"></script>
<script type="text/javascript">
    let vm = new Vue({
        el: '#app',
        data: {
            bmmc: '',
            ryxm: '',
            nf: '',      //--记录是否2021年，因为2021年数据格式不一致，用于隐藏两个表单
            tableTree: [],
            defaultProps: {},
            value2: [],

            dateBb: '',
            dateEe: '',
            ii_page: 1,   //--上一页下一页的计数器
            ii_row: 20,   //--每页显示的记录数
            iiCount: 0,
            tableData: [],      //--具体人员信息表
            fullscreenLoading: false,
        },
        methods: {
            fGet() {
                if (this.value2 === null) {
                    this.value2 = []
                    this.tableTree = []
                    return
                }

                this.dateBb = this.dateFormat(this.value2[0])
                this.dateEe = this.dateFormat(this.value2[1])
                if (this.dateBb.substr(0, 4) !== this.dateEe.substr(0, 4)) {
                    layer.msg('<span style="font-size:24px; line-height: 30px">历史数据不可跨年查询!</span>', {time: 2000, skin: 'fail'});
                    this.value2 = []
                    return
                }
                const date = new Date();
                if ((this.dateFormat(date).substr(0, 4) === this.dateBb.substr(0, 4)) || (this.dateFormat(date).substr(0, 4) === this.dateEe.substr(0, 4))) {
                    layer.msg('<span style="font-size:24px; line-height: 30px">当年数据无法进行历史查询!</span>', {time: 2000, skin: 'fail'});
                    this.value2 = []
                    return
                }
                this.nf = this.dateBb.substr(0, 4)

                //--获取对应年份中的对应部门
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "BD");
                params.append('VALUE01', this.dateBb.substr(0, 4));
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        //--db1左边表结构的树
                        let {db1} = res.data
                        self.tableTree = db1
                    })
                    .catch(function () {
                        layer.msg('<span style="font-size:24px; line-height: 30px">获取当年部门信息错误!</span>', {time: 2000, skin: 'fail'});
                    });
            },

            fReset() {
                this.yearnode = {}
                this.value2 = []
                this.sh = '0'
                this.ryxm = ''
                this.ii_page = 1   //--上一页下一页的计数器
                this.iiCount = 0
                this.tableData = []      //--具体人员信息表
                this.tableTree = []      //--
                this.bmmc = ''
            },

            fUp() {
                if (this.ii_page > 1) {
                    this.ii_page--;
                    this.fGetinfo()
                } else {
                    layer.msg('<span style="font-size:24px; line-height: 30px">已是第一页!</span>', {time: 2000, skin: 'fail'});
                }
            },

            fDown() {
                if (this.ii_page * 20 < this.iiCount) {
                    this.ii_page++;
                    this.fGetinfo()
                } else {
                    layer.msg('<span style="font-size:24px; line-height: 30px">已是最后一页!</span>', {time: 2000, skin: 'fail'});
                }
            },

            fBegin() {
                this.ii_page = 1
                this.fGetinfo()
            },

            fGetinfo() {
                if ((this.value2 === null) || (this.value2.length === 0)) {
                    layer.msg('<span style="font-size:24px; line-height: 30px">请选择查询的起止时间!</span>', {time: 2000, skin: 'fail'});
                    return
                }
                this.dateBb = this.dateFormat(this.value2[0])
                this.dateEe = this.dateFormat(this.value2[1])

                this.fullscreenLoading = true
                let self = this
                let params = new URLSearchParams();
                params.append('CMD', "BJ");
                params.append('VALUE01', ((this.ii_page - 1) * parseInt(this.ii_row)).toString());
                params.append('VALUE02', ((this.ii_page) * this.ii_row).toString());
                params.append('VALUE03', this.dateBb);
                params.append('VALUE04', this.dateEe);
                params.append('VALUE05', this.bmmc);
                params.append('VALUE06', this.ryxm);
                axios.post('/f_wscl/com2', params)
                    .then(function (res) {
                        let {db1, db2} = res.data
                        self.tableData = db1
                        self.iiCount = db2[0].VALUE01
                        self.idSum2 = db2[0].VALUE02
                    })
                    .catch(function () {
                        layer.msg('<span style="font-size:24px; line-height: 30px">网络异常错误!</span>', {time: 2000, skin: 'fail'});
                    }).finally(function () {
                    self.fullscreenLoading = false
                });
            },

            tableHeaderCellStyleL({row, column, rowIndex, columnIndex}) {
                let cellStyle1;

                cellStyle1 = "color: #fff;" +
                    "background:#4F4F4F;" +
                    "text-align:center;" +
                    "font-size:12px"

                return cellStyle1
            },

            tableCellStyleL({row, column, rowIndex, columnIndex}) {
                let cellStyle1;

                cellStyle1 = "text-align:center;" +
                    "padding:8px 1px 8px;" +
                    "font-size:12px"
                return cellStyle1;
            },

            dateFormat: function (time) {
                const date = new Date(time);
                const year = date.getFullYear();
                /* 在日期格式中，月份是从0开始的，因此要加0
                 * 使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
                 * */
                const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
                const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
                // 拼接
                return year + "-" + month + "-" + day;
            },

            fInit() {
            },
        },
        mounted() {
        },

        created() {
            let windowHeight = document.documentElement.clientHeight || document.body.clientHeight;
            this.tableHeightL = windowHeight - 85;
        }
    });

</script>

</body>
</html>
